package com.wjj.sixinone.controller.admin;


import com.wjj.sixinone.common.enums.ApiTypeConst;
import com.wjj.sixinone.common.pojo.vo.DepartmentForm;
import com.wjj.sixinone.common.pojo.vo.DepartmentVO;
import com.wjj.sixinone.common.util.Result;
import com.wjj.sixinone.service.DepartmentService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小王不秃头
 * @since 2024-07-22
 */
@RestController
@RequestMapping(ApiTypeConst.API_ADMIN+"/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @GetMapping("/selectDepartmentHeadByLimit")
    public Result selectDepartmentHeadByLimit(DepartmentVO departmentVO){
        return departmentService.selectDepartmentHeadByLimit(departmentVO);
    }

    @GetMapping("/uploadExcel")
    public void uploadExcel(HttpServletResponse httpServletResponse){
        departmentService.uploadExcel(httpServletResponse);
    }
    @PostMapping("/updateById")
    public Result updateById(@RequestBody DepartmentForm departmentForm){
        return departmentService.updateDepartmentById(departmentForm);
    }
    @PostMapping("/addDepartment")
    public Result addDepartment(@RequestBody DepartmentForm departmentFrom){
        return departmentService.addDepartment(departmentFrom);
    }
    @PostMapping("/deleteById")
    public Result deleteById(@RequestBody Map<String,String> map){
        String id = map.get("id");
        return departmentService.deleteById(id);
    }


}

